package com.naiterui.ehp.bs.doctor.controller.openapi;

import com.naiterui.ehp.bp.support.advice.IgnoreResponseEntityWrap;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bs.doctor.service.record.IRecordInfoService;
import com.naiterui.ehp.bs.doctor.vo.record.RecordResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author guoyongxiang
 * @date 2020/2/24 13:33
 * @since 1.0.0
 */
@Slf4j
@RequestMapping("ad/jgpt/services")
@RestController
public class SupervisePlatformHaiNanController {

    @Autowired
    @Qualifier("recordInfoDoctorServiceImpl")
    private IRecordInfoService recordInfoDrService;

    @IgnoreResponseEntityWrap
    @RequestMapping("up_doc_record_info")
    public Map<String, String> callback(RecordResultVO param) {

        Map<String, String> map = new HashMap<>();

        try {
            recordInfoDrService.saveCallback(param);
            map.put("status", "1");
            log.warn("备案平台，回调处理成功 param:{}", param);
        } catch (BusinessException e) {
            log.warn("备案平台，回调处理失败 param:{}, msg:{}", param, e.getMessage());
            map.put("status", "0");
        } catch (Exception e) {
            log.warn("备案平台，回调处理异常 param:{}, msg:{}", param, e.getMessage());
            map.put("status", "0");
        }
        return map;
    }
}
